<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml" xmlns:shiro="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<head th:include="include :: header">

</head>
<style>
	.main{
        margin: 16px 0 0 0;
        width:100%;
        height:auto;
    }
    .name{
        font-size: 14px;
        font-weight: bold;
        margin-top: 16px;
        height: 48px;
        line-height: 48px;
        padding-left: 16px;
        color: #3F4F60;
        border-radius: 4px;
        background: #fff;
    }
    .echart-box{
        background: #fff;
        padding: 16px;
        margin-bottom: 16px;
        border-radius: 4px;
    }
    .echart-box{
        clear: both;
        overflow: hidden;
    }
    .echart-box .item{
        float: left;
        width: 31%;
        margin-right: 2.333%;
        border-radius: 4px;
    }
    .echart-box .tit{
        font-size: 18px;
        margin-bottom: 24px;
        color: #06172A;
        position: relative;
        font-weight: bold;
        padding-left: 12px;
    }
    .echart-box .tit:after{
        content: '';
        width: 4px;
        height: 18px;
        background:var(--buttonborder);
        position: absolute;
        left: 0;
        top: 50%;
        margin-top: -8px;
    }
    .echart-box .text{
        color: #5a5f72;
        margin: 8px 0;
        position: relative;
        padding-left: 10px;
     }
    .echart-box .text:after{
        content: '';
        width: 4px;
        height: 14px;
        background: #2C82EB;
        position: absolute;
        left: 0;
        top: 50%;
        margin-top: -7px;
    }
    .echart-box .num{
        font-size: 30px;
        font-size: bold;
        padding-bottom: 8px;
        border-bottom: 1px solid #ccc;
    }
    .echart-box-two{
        background: #fff;
        padding: 18px;
    }
    .echart-box-two .item{
        background: #fff;
    }
    #oncescoreEcharts{
        padding-top: 20px;
        height:456px;
        border: 1px solid var(--buttonborder);
        border-radius: 4px
    }
    #mydiv1{
        flex-direction: var(--columnAndReverse);
    }
</style>
<body class="gray-bg" style="padding-right: 10px">
<div class="wrapper wrapper-content ">
    <p class="name">全国职业院校技能大赛中等职业教育 -- 婴幼儿照护赛项</p>
    <div id="main" class="main">
        <div class="echart-box-two echart-box">
            <div class="item" style="width: 100%">
                <p class="tit">各模块得分情况</p>
                <div  id="mydiv1" style="display: flex; ">

                    <div id="oncescoreEcharts"></div>
                    <table class="layui-table" style="min-height: 200px">
                        <thead id="myhead">

                        </thead>
                        <tbody id="mytabody">
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript" type="text/javascript" >
    var myChart1=null;
    let color=[]
    //获取
    let themeValue=[[${themeValue}]]
    switch (themeValue) {
        case '1':
            color=['#c205fa','#0547f5','#ff0404','#02fc63','#cecece','#ff7109']
            break;
        case '2':
            color=['#ba70d0','#5d7ed5','#f36969','#51af78','#cecece','#af6e3e']
            break;
    }
    $(function() {
        $.ajax({
            url: "/recordPoints/scoreInterval",
            type: "get",
            data: {
                year:$("#year").val()
            },
            success: function (res) {
                if(res==null){
                    layer.msg("未查询到数据！");
                }
                else {
                    let mydata1=`<tr><td>满分</td>`,
                        mydata2=`<tr><td>最高分</td>`,
                        mydata3=`<tr><td>最低分</td>`,
                        mydata4=`<tr><td>平均分</td>`,
                        mydata5=`<tr><td>分差值</td>`,
                        myhead=`<tr><th></th>`,
                        mydata=[[],[],[],[],[],[],[]]
                        myfenshhu=[30,15,10,10,35],
                        myfenshhuname=['满分','最高分','最低分','平均分','分差值'],
                        series=[]

                    for (let i = 0; i < res.data.data.length; i++) {
                        let item=res.data.data[i]
                        myhead+=`<th>${item.field}</th>  `
                        mydata1+=`<td>${myfenshhu[i]}</td>`
                        mydata2+=`<td>${parseFloat(item.highestScore).toFixed(2)}</td>`
                        mydata3+=`<td>${parseFloat(item.lowestScore).toFixed(2)}</td>`
                        mydata4+=`<td>${parseFloat(item.averageScore).toFixed(2)}</td>`
                        mydata5+=`<td>${parseFloat(item.scoreRange).toFixed(2)}</td>`

                        mydata[0].push(myfenshhuname[i])
                        mydata[1].push(myfenshhu[i])
                        mydata[2].push(parseFloat(item.highestScore).toFixed(2))
                        mydata[3].push(parseFloat(item.lowestScore).toFixed(2))
                        mydata[4].push(parseFloat(item.averageScore).toFixed(2))
                        mydata[5].push(parseFloat(item.scoreRange).toFixed(2))
                        mydata[6].push(item.field)
                    }
                    for (let i = 0; i < myfenshhuname.length; i++) {
                        series.push(  {
                            name: mydata[0][i],
                            type: i==myfenshhuname.length-1?'bar':'line',
                            color: color[i],
                            symbol:'none',
                            smooth:true,
                            data: mydata[i+1],
                            barWidth: '25%',
                            itemStyle: {
                                normal:{
                                    barBorderRadius: i==myfenshhuname.length-1?[100,100,0,0]:[]
                                }
                            }
                        },)
                    }
                    $('#mytabody').html(
                        mydata1+'</tr>'+
                        mydata2+'</tr>'+
                        mydata3+'</tr>'+
                        mydata4+'</tr>'+
                        mydata5+'</tr>'
                    )
                    $('#myhead').html(myhead+'</tr>')
                    intervalScoreEcharts(series,mydata[6])
                }
            }
        });

        window.onresize=()=>{
            myChart1?.resize()
        }
    })
    function intervalScoreEcharts(series,xdata){
        var dom = document.getElementById("oncescoreEcharts");
        myChart1 = echarts.init(dom);
        var option;
        option = {
            tooltip: {
                trigger: 'axis',
                formatter: function (params) {
                    let mytooltip=`${option.xAxis.data[params[0].dataIndex]}<br/>`
                    for (let i = 0; i < params.length; i++) {
                        let item=params[i]
                        mytooltip+=`${item.seriesName}：${item.value}<br/>`
                    }
                    return mytooltip
                },
            },
            legend: {
                x: 'center', // 图例水平居中
                y: 'top', // 图例垂直居上
                itemWidth:20
            },
            grid: {
                top: '18%',
                left: '10%',  // grid布局设置适当调整避免X轴文字只能部分显示
                right: '10%', // grid布局设置适当调整避免X轴文字只能部分显示
                bottom: '15%',
                containLabel: true, //防止坐标轴溢出
            },
            xAxis: {
                type: 'category',
                data:xdata,
                axisLabel: {
                    show: true, // 是否显示刻度标签，默认显示
                    interval: 0, // 坐标轴刻度标签的显示间隔，在类目轴中有效；默认会采用标签不重叠的策略间隔显示标签；可以设置成0强制显示所有标签；如果设置为1，表示『隔一个标签显示一个标签』，如果值为2，表示隔两个标签显示一个标签，以此类推。
                    rotate: 0, // 刻度标签旋转的角度，在类目轴的类目标签显示不下的时候可以通过旋转防止标签之间重叠；旋转的角度从-90度到90度
                    inside: false, // 刻度标签是否朝内，默认朝外
                    margin: 16, // 刻度标签与轴线之间的距离
                    //formatter: '{value} ' , // 刻度标签的内容格式器
                    color:'#3F4F60',
                },
            },
            yAxis: {
                type: 'value',
            },
            series
        };
        if (option && typeof option === 'object') {
            myChart1.setOption(option);
        }
    }
</script>
</body>
</html>